<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>TestJackSon</title>
    <script type="text/javascript" src="/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $(".click").click(function () {
                $.get("/springmvc/testJackson", function (data, status) {
                    alert(status);
                    if (status === "success") {
                        alert(JSON.stringify(data));
                        var ul = document.createElement("ul");
                        var li1 = document.createElement("li");
                        var li2 = document.createElement("li");
                        var li3 = document.createElement("li");
                        var li4 = document.createElement("li");
                        var li5 = document.createElement("li");
                        var date = new Date(data.birth);
                        li1.innerHTML = "username: " + data.username;
                        li2.innerHTML = "age: " + data.age;
                        li3.innerHTML = "birth: " + date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDay();
                        li4.innerHTML = "address: " + data.address.city;
                        li5.innerHTML = "salary: " + data.salary;
                        ul.appendChild(li1);
                        ul.appendChild(li2);
                        ul.appendChild(li3);
                        ul.appendChild(li4);
                        ul.appendChild(li5);
                        $("#datashow").append('<h3>User 数据</h3>');
                        $("#datashow").append(ul);
                    }
                });
                return false;
            });
        });
    </script>
</head>
<body>
<h3>
    <button class="click">获取json数据</button>
</h3>
<div id="datashow">
</div>
</body>
</html>
